(function (vc) {
    vc.extends({
        propTypes: {
            emitChooseShopVipUser: vc.propTypes.string,
            emitLoadData: vc.propTypes.string
        },
        data: {
            chooseShopVipUserInfo: {
                shopVipUsers: [],
                _currentShopVipUserName: '',
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('chooseShopVipUser', 'openChooseShopVipUserModel', function (_param) {
                $('#chooseShopVipUserModel').modal('show');
                $that._refreshChooseShopVipUserInfo();
                $that._loadAllShopVipUserInfo(1, 10, '');
            });
        },
        methods: {
            _loadAllShopVipUserInfo: function (_page, _row, _name) {
                var param = {
                    params: {
                        page: _page,
                        row: _row,
                        shopId: vc.getCurrentCommunity().shopId,
                        name: _name
                    }
                };

                //发送get请求
                vc.http.apiGet('/shopVipUser.queryShopVipUser',
                    param,
                    function (json) {
                        var _shopVipUserInfo = JSON.parse(json);
                        $that.chooseShopVipUserInfo.shopVipUsers = _shopVipUserInfo.data;
                    }, function () {
                        console.log('请求失败处理');
                    }
                );
            },
            chooseShopVipUser: function (_shopVipUser) {
                if (_shopVipUser.hasOwnProperty('name')) {
                    _shopVipUser.shopVipUserName = _shopVipUser.name;
                }
                vc.emit($props.emitChooseShopVipUser, 'chooseShopVipUser', _shopVipUser);
                $('#chooseShopVipUserModel').modal('hide');
            },
            queryShopVipUsers: function () {
                $that._loadAllShopVipUserInfo(1, 10, $that.chooseShopVipUserInfo._currentShopVipUserName);
            },
            _refreshChooseShopVipUserInfo: function () {
                $that.chooseShopVipUserInfo._currentShopVipUserName = "";
            }
        }

    });
})(window.vc);
